<?php
/**
 * 提现管理
 * @author Administrator
 */
class withdraw extends admin{
   public function __construct(){
      parent::__construct();
      array_walk_recursive($_GET,'safe_filter');
      array_walk_recursive($_POST,'safe_filter');
   }

   //提现列表
   public function index(){
      $start = isset($_GET['time'][0])&&!empty($_GET['time'][0])?strtotime($_GET['time'][0]):0;
      $end = isset($_GET['time'][1])&&!empty($_GET['time'][1])?strtotime($_GET['time'][1]):NOW;
      $where =' where apply_time between '.$start.' and '.$end;
      $school_id=(int)$_SESSION['client']['jx_id'];
      $where.= ' and school_id='.$school_id;
      if(isset($_GET['audit_status'])&&is_numeric($_GET['audit_status'])) $where.=' and audit_status='.(int)$_GET['audit_status'];
      if(isset($_GET['pay_status'])&&is_numeric($_GET['pay_status'])) $where.=' and pay_status='.(int)$_GET['pay_status'];
      $mo=$_GET['mobile'];
      if ($mo!='') $where .= " and mobile like '%$mo%'";

      $total=db()->getOne('select count(*) from x_withdraw '.$where);
      $pagesize = C('PAGE_SIZE');
      if (isset($_GET['p']) && (int) $_GET['p'] > 0) $p = (int) $_GET['p'];
      else $p = 1;
      $limit=' limit '.($p-1)*$pagesize.','.$pagesize;
      $list=db()->getAll('select * from x_withdraw '.$where.' order by id DESC'.$limit);
      if(!$list) $list=array();
      $page = array('total' => $total, 'pagesize' =>$pagesize, 'curpage' => $p);
      $this->ajaxReturn(array('status'=>1,'data'=>$list,'page'=>$page));
   }


   //审核
   public function update(){
      $id=$_POST['id'];
      if($id<=0) $this->ajaxReturn(array('status'=>'n','info'=>'参数错误'));
      $data['audit_status']=(int)$_POST['audit_status'];
      $data['remark']=remove_xss($_POST['remark']);
      $data['audit_time']=NOW;
      $affert_rows=db()->update('x_withdraw',$data,'id='.$id);
      if($affert_rows) $this->ajaxReturn(array('status'=>'1','info'=>'操作成功'));
      else $this->ajaxReturn(array('status'=>'0','info'=>'操作失败'));

    }




}
